<?php
apf_require_class('APF_Controller');
apf_require_class('Solr_Bll_AppBiz');
apf_require_controller('Application_List');
class Application_AddController extends APF_Controller {

    public static function build_uri() {
        $base_domain = APF::get_instance()->get_config("base_domain");
        $schema = APF::get_instance()->get_request()->is_secure() ? "https" : "http";
        $url = "{$schema}://{$base_domain}/application/add/";
        return $url;
    }

    public function handle_request() {
        $request = APF::get_instance()->get_request();
        $params = $request->get_parameters();
        $app_biz=Solr_Bll_AppBiz::get_instance();
        $app_biz->insert_application($params['hostname_id'],$params['webapp_id'],$params['memo']);
        APF::get_instance()->get_response()->redirect(Application_ListController::build_uri().'?hostname_id='.$params['hostname_id'].'&webapp_id='.$params['webapp_id']);
        return false;
    }
}